import Vue from 'vue'
import VueRouter from 'vue-router'
// 它会默认寻找文件夹下的index.vue
import Login from '../views/login'
import Home from '../views/home'
import GoodAdd from '../views/goods/goodAdd'
import GoodList from '../views/goods/goodList'
import User from '../views/user'

Vue.use(VueRouter)

//redirect不能重定向到组件中去,只能重定向到路由路径中
const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  },
  {
    path: '/home',
    name: 'home',
    component: Home,
    children: [
      {
        path: '/users',
        name: 'User',
        component: User
      },
      {
        path: '/goodList',
        name: 'goodList',
        component: GoodList
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
